<?php
/*
 * @Description: 
 * @Author: Leequik
 * @Date: 2025-07-23 21:54:40
 * @LastEditTime: 2025-07-23 22:11:51
 * @LastEditors: Leequik
 */

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class TestEvent
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $type;
    public $expire;
    public $msg;

    /**
     * Create a new event instance.
     */
    public function __construct($type,$expire,$msg)
    {
        $this->type = $type;
        $this->expire = $expire;
        $this->msg = $msg;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return array<int, \Illuminate\Broadcasting\Channel>
     */
    public function broadcastOn(): array
    {
        return [
            new PrivateChannel('channel-name'),
        ];
    }

    public function trigger_event()
    {
        echo json_encode([
            'type' => $this->type,
            'expire' => $this->expire,
            'msg' => $this->msg,
        ]);
    }
}
